package 笔试.顺丰;

import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/9/6-21:05
 * @version:1.0
 * @function:
 */
public class Main04 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int res = 0;
        for (int i = 0; i < n; i++) {
            System.out.println(fun(scanner.nextInt()));
//            if (fun(scanner.nextInt())) {
//                res++;
//            }
        }
        System.out.println(res);
    }

    private static boolean fun(int num) {
        String temp = String.valueOf(num);
        int count = temp.charAt(0) - '0';
        for (int i = 1; i < temp.length() - 1; i++) {
            int n = temp.charAt(i) - '0';
            if (n >= count) count = n;
            else return false;
        }
        if (count == temp.charAt(temp.length() - 1) - '0')
            return true;
        else
            return false;
    }
}
